package com.example.demo.Excel;

import com.alibaba.excel.EasyExcel;
import com.example.demo.pojo.Competitions.CompetitionScore;
import com.example.demo.pojo.Competitions.CompetitionScoreDTO;
import com.example.demo.pojo.Order.Orders;
import com.example.demo.pojo.Order.PutOrders;
import com.example.demo.pojo.Stock.StockPositions;
import com.example.demo.pojo.User.ExcelUserLoginLogDto;
import com.example.demo.pojo.User.User;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExcelExportService {
    /**
     * 委托订单Excel导出
     */
    public void exportPutOrders(List<PutOrders> orders, String fileName) {
        EasyExcel.write(fileName, PutOrders.class).sheet("委托订单数据").doWrite(orders);
    }

    /**
     * 新，委托订单Excel导出
     */
    public void exportPutOrdersNew(List<Orders> orders, String fileName) {
        EasyExcel.write(fileName, Orders.class).sheet("委托订单数据").doWrite(orders);
    }

    /**
     * 成交订单Excel导出
     */
    public void exportOrders(List<Orders> orders, String fileName) {
        EasyExcel.write(fileName, Orders.class).sheet("成交订单数据").doWrite(orders);
    }

    /**
     * 持仓信息Excel导出
     */
    public void exportStockPositions(List<StockPositions> stockPositions, String fileName) {
        EasyExcel.write(fileName, StockPositions.class).sheet("持仓信息数据").doWrite(stockPositions);
    }

    /**
     * 用户信息Excel导出
     */
    public void exportUser(List<User> users, String fileName) {
        EasyExcel.write(fileName, User.class).sheet("用户信息数据").doWrite(users);
    }

    /**
     * 比赛排名信息Excel导出
     */
    public void exportCompetitionScore(List<CompetitionScoreDTO> competitionScores, String fileName) {
        EasyExcel.write(fileName, CompetitionScore.class).sheet("用户信息数据").doWrite(competitionScores);
    }

    /**
     * 用户登录日志信息Excel导出
     */
    public void exportUserLoginLog(List<ExcelUserLoginLogDto> userLoginLogDtos, String fileName) {
        EasyExcel.write(fileName, ExcelUserLoginLogDto.class).sheet("用户登录日志").doWrite(userLoginLogDtos);
    }
}
